<?php
class SystemController extends NodeController {
	
	public function config() {
		$config = require_once 'base.php';
		$this->view ()->assign ( 'config', $config );
		$this->login ();
		$ini = ini_get_all ();
		$mysqlversion = SystemModel::instance ()->getVersion ();
		$this->view ()->assign ( 'zone', $ini ['date.timezone'] ['local_value'] );
		$this->view ()->assign ( 'ini', $ini );
		$mysqlsize = SystemModel::instance ()->getDbSize ();
		$system = array ('sys' => php_uname ( "s" ), 'phpapi' => php_sapi_name (), 'phpversion' => PHP_VERSION, 'mysql' => $mysqlversion ['VERSION()'], 'mysqlsize' => $mysqlsize );
		$this->view ()->assign ( 'system', $system );
		$this->view ()->display ( "file:system/config.tpl" );
	}
	
	/**
	 * 最近30天的登录情况 图表显示
	 */
	public function login() {
		$days = isset ( $_GET ['days'] ) ? $_GET ['days'] : 30;
		$format = isset ( $_GET ['format'] ) ? $_GET ['format'] : "d";
		$rs = self::getLogService ()->getLoginStatus ( $format, $days );
		
		$this->view ()->assign ( 'log', $rs );
	}
	
	private function getMaxValue($value) {
		
		$max = 0;
		foreach ( $value as $v ) {
			if ($v > $max) {
				$max = $v;
			}
		}
		return $max;
	}
}
